package com.project8.main;

import com.project8.book.Book;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TabHost;

public class Tables extends TabActivity
{
	Bundle bundle = new Bundle();
	Book book;
	String glossTerm;
	boolean shouldDisplayGlossaryFirst;
	
	public void onCreate(Bundle savedInstanceState) 
	{
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.tables);

	    Resources res = getResources(); // Resource object to get Drawables
	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    SeekBar brightnessBar = brightnessBar = (SeekBar)findViewById(R.id.brightnessBar);
		BrightnessSettings bright = new BrightnessSettings(this, brightnessBar, getWindow(), getContentResolver());
	    
	    bundle = getIntent().getExtras();
		book = Global.books.get(bundle.getInt("bookIndex"));//book = (Book) bundle.get("Book");
		glossTerm = (String) bundle.getString("Glossary");
		shouldDisplayGlossaryFirst = (boolean) bundle.getBoolean("ShowGloss");
		bundle.putSerializable("Book", book);
		
		System.out.println("In Tables: " + this.shouldDisplayGlossaryFirst);
		
	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, TableOfContent.class);
	    intent.putExtras(bundle);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("Table of Contents").setIndicator("Table of Contents", res.getDrawable(R.drawable.icon_list_bullets)).setContent(intent);
	    tabHost.addTab(spec);

	    intent = new Intent().setClass(this, TableOfFigure.class);
	    intent.putExtras(bundle);
	    spec = tabHost.newTabSpec("Table of Figures").setIndicator("Table of Figures", res.getDrawable(R.drawable.icon_photo)).setContent(intent);
	    tabHost.addTab(spec);
	    
	    bundle.putSerializable("Glossary", glossTerm);
	    intent = new Intent().setClass(this, Glossary.class);
	    intent.putExtras(bundle);
	    spec = tabHost.newTabSpec("Glossary").setIndicator("Glossary", res.getDrawable(R.drawable.icon_sort_az)).setContent(intent);
	    tabHost.addTab(spec);

	    if(shouldDisplayGlossaryFirst)
	    	tabHost.setCurrentTab(2);
	    else
	    	tabHost.setCurrentTab(0);
	}
}
